import { NestFactory } from "@nestjs/core";
import { AppModule } from "./app.module";
import { Logger } from "winston";
import { HttpExceptionFilter } from "./common/http-exception";
import logger from "./utils/logger";
import { WinstonModule } from "nest-winston";

const port = 8080;

async function bootstrap() {
  const app = await NestFactory.create(AppModule, {
    logger: WinstonModule.createLogger({
      instance: logger,
    }),
  });
  app.useGlobalFilters(new HttpExceptionFilter());
  const env = process.env.env || "online";
  if (env !== "online") {
    await app.enableCors();
  }
  await app.listen(port);
  console.log(`Application is running on: ${await app.getUrl()}`);
}
bootstrap();
